package chloroform

import _root_.util.logging.Logged
import org.python.core.{PyString, PyObject}
import scaladuct.python.JythonObjectFactory
import scaladuct.{Property, ConfigPageGateway}
import collection.immutable.List
import argo.jdom.{JsonStringNode, JsonNode}
import chloroform.l10n.{ProjectLocale}

/**
 * <p>
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Jan 19, 2011
 * Time: 7:37:59 PM
 */
trait CompositeJsonCookieHandler extends JsonCookieHandler with JsonProjectHandler

abstract class PyductConfigSessionHandler extends CompositeJsonCookieHandler with Logged {
//  private var h: JsonCookieHandler with JsonProjectHandler = null
//
//  def handler = if (h != null) h else {
//    val factory: JythonObjectFactory = JythonObjectFactory.getInstance()
//    h = factory.createObject(classOf[CompositeJsonCookieHandler],
//      "pyduct.defaultConfiguration",
//      "CookieHandler")
//    h
//  }
//
//  def getCookieMessageBuilder(gateway: ConfigPageGateway[_]) =
//    handler.getCookieMessageBuilder(gateway)
//
//  def updateCookie(gateway: ConfigPageGateway[_], responseMap: java.util.Map[JsonStringNode, JsonNode]) =
//    handler.updateCookie(gateway, responseMap)
//
//  def getHintsBuilder(gateway: ConfigPageGateway[_], hints: List[Property[Any]]) =
//    handler.getHintsBuilder(gateway, hints)
//
//  def updateHints(gateway: ConfigPageGateway[_], selectedHint: Property[Any], newValue: JsonNode): Property[Any] =
//    handler.updateHints(gateway, selectedHint, newValue)
//
//  def getResultBuilder(gateway: ConfigPageGateway[_]) =
//    handler.getResultBuilder(gateway)
//
//  def getEndBuilder() =
//    handler.getEndBuilder()
//
//  def getProjectEntriesBuilder(project: Project with ProjectLocale, scenario: String = null) =
//    {
//      val jsonCookieHandler: JsonCookieHandler with JsonProjectHandler = handler
//      debug("Beginning building JSON model for project without init of the handler")
//      val ts = System.currentTimeMillis
//      try {
//        jsonCookieHandler.getProjectEntriesBuilder(project, scenario)
//      }
//      finally {
//        debug("Building JSON model for project without init of the handler: " + (System.currentTimeMillis - ts) / 1000)
//      }
//    }
//
//  def getSelectedProjectEntriesBuilder(project: Project with ProjectLocale, entries: List[ProjectEntry]) =
//    handler.getSelectedProjectEntriesBuilder(project, entries)
//
}
